package com.scs.application.modules.wm.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.scs.application.core.query.QueryContext;
import com.scs.application.core.service.IBaseService;
import com.scs.application.modules.base.entity.Location;
import com.scs.application.modules.wm.dto.DeliveryDTO;
import com.scs.application.modules.wm.dto.OrthWiDTO;
import com.scs.application.modules.wm.dto.StockByPackTempDTO;
import com.scs.application.modules.wm.entity.WorkOrder;
import com.scs.application.modules.wm.entity.WorkOrderItem;
import com.scs.application.utils.ImportResult;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * <p>
 * 入库单明细 Service
 * </p>
 */

public interface InOrderItemService extends IBaseService<WorkOrderItem> {

    /**
     * 根据送货单明细保存送货单明细
     *
     * @param deliveryDTOItemList
     * @param workOrderId
     * @param qrCodeInOrder 是否二维码入库，如果是的话，需要检查是否重复入库
     * @return
     */
    List<WorkOrderItem> saveOrderItemByDelivery(List<DeliveryDTO.DeliveryItemDTO> deliveryDTOItemList, String workOrderId, String warehouseId, boolean qrCodeInOrder,DeliveryDTO deliveryDTO);

    /**
     * 根据出库单明细生成入库单明细
     * @param outWorkOrderItemList
     * @param workOrderId
     * @param locationId
     */
    void saveOrderItemByOutOrder(List<WorkOrderItem> outWorkOrderItemList, String workOrderId, String warehouseId,String locationId);

    /**
     * 入库查找stockId
     * @return
     */
    List<WorkOrderItem> getLineId(String workOrderId, String workOrderItemId);

    /**
     * 跟台包入库
     * @param stockByPackTempDTO
     * @return
     */
    boolean addByPackTemp(StockByPackTempDTO stockByPackTempDTO);

    /**
     * 修改包装数量
     * @return
     */
    void updateQty(WorkOrderItem workOrderItem);

    /**
     * 删除跟台包及包内耗材
     * @param id
     */
    void deletePackage(String id);

    /**
     * 删除跟台包内耗材并更新价格
     * @param id
     */
    void deleteMatr(String id);

    /**
     * 重写inorderItem的Page
     *
     * @param context
     * @return
     */
    Page<WorkOrderItem> inorderItemPage(QueryContext context);

    @Transactional(rollbackFor = Exception.class)
    void splitOrderItem(WorkOrderItem workOrderItem);

    /**
     * @param orthWiDTO
     * @param workOrder
     * @param warehouseId
     * @param location
     * @param packId
     * @param sumOrthWiItemQty
     */
    void saveOrderItemByOrthScan(OrthWiDTO orthWiDTO, WorkOrder workOrder, String warehouseId, Location location, String packId, double sumOrthWiItemQty);

    void downloadExcelTemp(HttpServletResponse response, String deliveryId);

    ImportResult importDtl(MultipartFile file, String deliveryId);
}
